from time import sleep

from appium import webdriver

desired_caps = {
    "platformName": "Android",
    "platformVersion": "7.1.2",  # 你的模拟器安卓版本
    "deviceName": "127.0.0.1:62001",  # 你的 adb devices 显示的设备名
    "appPackage": "com.jingdong.app.mall",
    "appActivity": "com.jingdong.app.mall.MainFrameActivity",
    "noReset": True,
    "automationName": "UiAutomator2"
}
desired_caps2 = {
    "platformName": "Android",
    "platformVersion": "11",
    "deviceName": "9b73bdfb",
    "appPackage": "com.palmpi.live2d.wallpaper",
    "appActivity": "com.palmpi.live2d.wallpaper.ui.activity.homePage.HomePageActivity",
    "automationName": "UiAutomator2",
    # 加入以下配置避免触发 hidden_api_policy 修改报错
    "skipServerInstallation": True,
    "skipDeviceInitialization": True,
    "noReset": False,  # 改为 True，防止频繁重装和清除数据
    "dontStopAppOnReset": True,  # 启动时不停止 app，减少冲突
    "disableWindowAnimation": True,  # 加快测试效率，防止动画干扰
}
driver = webdriver.Remote("http://localhost:4723", desired_caps)